<?php

namespace Part02_StrategyMode\Code3;

class CashFactory
{
    /**
     * @throws \Exception
     */
    public static function createAccept($type)
    {
        switch ($type) {
            case '正常收费':
                return new CashNormal();
            case '满300返100':
                return new CashReturn(300, 100);
            case '打8折':
                return new CashRebate(0.8);
            default:
                throw new \Exception('未知折扣');
        }
    }
}